<?php

	require_once("fta.201003310000/fta.php");
	fta_registerModules(
		array(
		"cms.201003310000/config/cmsConfig",//we will deprecate the old cms config soon..
		"site/fta/config",
		"site/components/MAIExhibition",
		"FTAWebPage/ftaDefaultWidgets",
		"FTAWebPage/FTAWebPage",
	));

	$exhibitionList = extractStringWithKeyFromArray("exhibitionList", $_REQUEST, null);
	$exhibitionDate = extractStringWithKeyFromArray("exhibitionDate", $_REQUEST, null);
	if(is_null($exhibitionList) && is_null($exhibitionDate)){
		header("location: /Exhibitions/");
	}

	if(!is_null($exhibitionDate)){
		if(strtotime($exhibitionDate) > strtotime(date("Y-m-d"))){
			$exhibitionList = 'Coming-Exhibitions';
		} elseif(strtotime($exhibitionDate) < strtotime(date("Y-m-d"))){
			$exhibitionList = 'Past-Exhibitions';
		} else {
			$exhibitionList = 'Currently-Showing';
		}
	}

	$exhibitionTitle = str_replace("-", " ",$exhibitionList);

	function renderExhibitionItem($item){

		if(strlen($item->extra11) > 0){
		?>
		<img src="/html/blob.php?documentCode=<?php echo $item->documentcode; ?>&elementId=20200&filetypecode=2" class="img-l" />
		<?php
		}  else {
		?>
			<img src="/images/placeHolder-class.gif" class="img-l" />
		<?php
		}
		?>
        <div>
            <h3><?php echo $item->title; ?></h3>

            <h5>Opens <?php echo date("M j", strtotime($item->documentdate)); ?> <?php echo $item->content; ?><br />
            <?php echo date("M j", strtotime($item->startdate)); ?> - <?php echo date("M j", strtotime($item->enddate)); ?></h5>

            <?php echo $item->authordepartment; ?>

            <?php if($item->extra13 == '1' && (strtotime($item->documentyear) > strtotime("now"))){ ?>

        	<form name="exhibition-enrolement-<?php echo $item->documentcode; ?>" id="submit-enrolment-<?php echo $item->documentcode; ?>" method="POST" action="/Exhibitions/Entry-Forms/"><input type="hidden" name="exhibition" value="<?php echo $item->documentcode; ?>" /><input class="exhibition-enrol-submit" type="submit" value="Enrol" /></form>
        <?php } ?>


        </div>

		<?php



	}

	global $FTAWebPageDocumentType;
	$FTAWebPageDocumentType = 'pagebuilder';

?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php echo fta_getPageKeywords("/" . $exhibitionList . "/"); ?>
<?php echo fta_getPageDescription("/" . $exhibitionList . "/"); ?>

<title><?php echo $exhibitionTitle; ?> - Exhibitions | Mairangi Arts Centre</title>

<meta property="og:title" content="<?php echo $exhibitionTitle; ?> - Exhibitions | Mairangi Arts Centre" />

<?php include ("includes/external-files.php"); ?>




<?php include ("includes/analytics.php"); ?>
</head>

<body id="exhibitions" class="exhibitions-list-page">



<?php include ("includes/head.php"); ?>





<div id="container">


	<div id="content">




        <div id="content-blocks">
		<a href="/Events-Calendar/" class="button view-calendar">View the Calendar</a>


        <h1><a href="/Exhibitions/"><?php echo $exhibitionTitle; ?></a></h1>

<div class="share-twitter">
    <a href="https://twitter.com/share" class="twitter-share-button" data-lang="en">Tweet</a>
    <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</div>


<div class="share-facebook">
    <div id="fb-root"></div>
    <script>(function(d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return;
    js = d.createElement(s); js.id = id;
    js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
    fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script>

    <div class="fb-like" data-send="false" data-width="450" data-show-faces="false"></div>
</div>



            <div class="content-block">
            <?php echo mai_renderExhibitionList($exhibitionList); ?>
            <?php /* ?>
            <ul class="exhibition-list">
            	<li>
                	<img src="http://placehold.it/200x180/e5e5e5&text=Class+image" class="img-l" />
                    <div>
                        <h3>Seeing Red</h3>

                        <h5>Opens 7 Aug 4-6pm<br />
                        7 Aug – 21 Aug*</h5>

                        Contrasting works in a range of media and styles by Mairangi Arts Centre students under the tutelage of artist Karl Amundsen. (Main Gallery)
                    </div>
				</li>
            	<li>
                	<img src="http://placehold.it/200x180/e5e5e5&text=Class+image" class="img-l" />
                    <div>
                        <h3>In2Art</h3>

                        <h5>Opens 5.30pm 24 Aug<br />
                        24 Aug – 2 Sept</h5>

                        The best of North Shore Intermediate Schools’ students’ artworks. Come and view these promising young artists’ talent. (Main & Hewson Galleries)
                    </div>

				</li>
            	<li>
                	<img src="http://placehold.it/200x180/e5e5e5&text=Class+image" class="img-l" />
                    <div>
                        <h3>Seathreads</h3>

                        <h5>Opens 2pm 4 Sept<br />
                        4 Sept-18 September</h5>

                        An exhibition featuring beautiful spinning, weaving and textile artworks.
                    </div>
				</li>





			</ul>
			<?php */ ?>

            </div><!-- content-block ends -->


		</div><!-- Content-blocks ends -->




   </div><!-- Content ends -->












	<div id="sub-nav">
    	<ul id="sub-nav-list">
        	<li <?php if($exhibitionList == "Currently-Showing"){ echo "class='selected'";} ?>><h3><a href="/Exhibitions/Currently-Showing/" title="">Currently Showing</a></h3></li>
        	<li <?php if($exhibitionList == "Coming-Exhibitions"){ echo "class='selected'";} ?>><h3><a href="/Exhibitions/Coming-Exhibitions/" title="">Coming Exhibitions</a></h3></li>
        	<li <?php if($exhibitionList == "Past-Exhibitions"){ echo "class='selected'";} ?>><h3><a href="/Exhibitions/Past-Exhibitions/" title="">Past Exhibitions</a></h3></li>
        	<li><h3><a href="/Exhibitions/Entry-Forms/" title="">Entry Forms</a></h3></li>
        </ul>
    </div><!-- Sub-nav ends -->




</div><!-- Container ends -->




<?php include ("includes/foot.php"); ?>





</body>

</html>
